let a = 1;

function speak(num){
    num= 2;
    console.log(num) // 2
}
speak(a)
console.log(a) // 1


let obj = {
    name:'ck',
    age:19
}

function launch(obj){
    obj.name = 'kb'
    console.log(obj.name) // kb
}

console.log(obj.name) // ck
launch(obj)
// 所以， 只要obj被当作参数传递了， 那么就会被修改
console.log(obj.name) // kb

function changeObj(obj){
    this.obj = obj
    this.obj.name = 'new'
    console.log(this.obj.name) // new
}

changeObj(obj)
console.log(obj.name) // new


function cloneObjAndChange(obj) {
    // 这样这里使用的就是深拷贝后的数据对象 不是原来外部的数据对象
    obj = JSON.parse(JSON.stringify(obj))
    obj.name = 'hahha'
    console.log(obj.name)
}

console.log(obj.name)
cloneObjAndChange(obj)
console.log(obj.name)

let arr = new Array(10).fill('1')
// console.log(arr)


let objV3 = {name:'nameV3'}
function cloneV3(obj){
    objV3 = obj
    obj.name = 'change'+obj.name
    objV3.name = 'change'+objV3.name

    console.log(obj.name)
    console.log(objV3.name)
}
cloneV3(obj)

console.log(objV3.name);


console.log(undefined === undefined)
